# CONFIG_QEMU ?= ../qemu-xen.git
CONFIG_QEMU ?= $(QEMU_REMOTE)
-QEMU_TAG ?= b7754ca4a80e9a53b848796c860d19d6fa7a6d08
-# Thu Dec 23 15:21:52 2010 +0000
-# qemu-xen: update for libxc evtchn interface change
+QEMU_TAG ?= ead83f3f9bc4516f845fbbe23204872eed3e8432
+# Thu Dec 23 15:29:37 2010 +0000
+# qemu-xen: update for libxc gnttab interface change
# Optional components
XENSTAT_XENTOP ?= y
}
xenbus_write_backend_state(mount, STATE_CLOSED);
- xc_gnttab_munmap(mount->xch, mount->gnth,
- mount->ring.sring, mount->shared_ring_size);
- xc_gnttab_close(mount->xch, mount->gnth);
+ xc_gnttab_munmap(mount->gnth, mount->ring.sring, mount->shared_ring_size);
+ xc_gnttab_close(mount->gnth);
xc_evtchn_unbind(mount->evth, mount->local_evtchn);
xc_evtchn_close(mount->evth);
FS_DEBUG("ERROR: Couldn't bind evtchn!\n");
goto error;
}
- mount->gnth = -1;
- mount->gnth = xc_gnttab_open(mount->xch);
- if (mount->gnth < 0) {
+ mount->gnth = NULL;
+ mount->gnth = xc_gnttab_open(NULL, 0);
+ if (mount->gnth == NULL) {
FS_DEBUG("ERROR: Couldn't open gnttab!\n");
goto error;
}
for(i=0; i<mount->shared_ring_size; i++)
dom_ids[i] = mount->dom_id;
- sring = xc_gnttab_map_grant_refs(mount->xch, mount->gnth,
+ sring = xc_gnttab_map_grant_refs(mount->gnth,
mount->shared_ring_size,
dom_ids,
mount->grefs,
error:
xenbus_write_backend_state(mount, STATE_CLOSED);
if (sring)
- xc_gnttab_munmap(mount->xch, mount->gnth,
- mount->ring.sring, mount->shared_ring_size);
- if (mount->gnth > 0)
- xc_gnttab_close(mount->xch, mount->gnth);
+ xc_gnttab_munmap(mount->gnth, mount->ring.sring, mount->shared_ring_size);
+ if (mount->gnth != NULL)
+ xc_gnttab_close(mount->gnth);
if (mount->local_evtchn > 0)
xc_evtchn_unbind(mount->evth, mount->local_evtchn);
if (mount->evth != NULL)
xc_interface *xch; /* just for error logging, so a dummy */
xc_evtchn *evth; /* Handle to the event channel */
evtchn_port_t local_evtchn;
- int gnth;
+ xc_gnttab *gnth;
int shared_ring_size; /* in pages */
struct fsif_back_ring ring;
int nr_entries;
FS_DEBUG("Dispatching file open operation (gref=%d).\n", req->u.fopen.gref);
/* Read the request, and open file */
- file_name = xc_gnttab_map_grant_ref(mount->xch, mount->gnth,
+ file_name = xc_gnttab_map_grant_ref(mount->gnth,
mount->dom_id,
req->u.fopen.gref,
PROT_READ);
}
}
out:
- if (xc_gnttab_munmap(mount->xch, mount->gnth, file_name, 1) != 0) {
+ if (xc_gnttab_munmap(mount->gnth, file_name, 1) != 0) {
FS_DEBUG("ERROR: xc_gnttab_munmap failed errno=%d\n", errno);
terminate_mount_request(mount);
}
assert(req->u.fread.len > 0);
count = (req->u.fread.len - 1) / XC_PAGE_SIZE + 1;
assert(count <= FSIF_NR_READ_GNTS);
- buf = xc_gnttab_map_domain_grant_refs(mount->xch, mount->gnth,
+ buf = xc_gnttab_map_domain_grant_refs(mount->gnth,
count,
mount->dom_id,
req->u.fread.grefs,
priv_req->aiocb.aio_sigevent.sigev_value.sival_ptr = priv_req;
if (aio_read(&priv_req->aiocb) < 0) {
FS_DEBUG("ERROR: aio_read failed errno=%d\n", errno);
- xc_gnttab_munmap(mount->xch, mount->gnth,
- priv_req->page, priv_req->count);
+ xc_gnttab_munmap(mount->gnth, priv_req->page, priv_req->count);
terminate_mount_request(mount);
}
uint16_t req_id;
/* Release the grant */
- if (xc_gnttab_munmap(mount->xch, mount->gnth,
+ if (xc_gnttab_munmap(mount->gnth,
priv_req->page, priv_req->count) != 0) {
FS_DEBUG("ERROR: xc_gnttab_munmap failed errno=%d\n", errno);
terminate_mount_request(mount);
assert(req->u.fwrite.len > 0);
count = (req->u.fwrite.len - 1) / XC_PAGE_SIZE + 1;
assert(count <= FSIF_NR_WRITE_GNTS);
- buf = xc_gnttab_map_domain_grant_refs(mount->xch, mount->gnth,
+ buf = xc_gnttab_map_domain_grant_refs(mount->gnth,
count,
mount->dom_id,
req->u.fwrite.grefs,
priv_req->aiocb.aio_sigevent.sigev_value.sival_ptr = priv_req;
if (aio_write(&priv_req->aiocb) < 0) {
FS_DEBUG("ERROR: aio_write failed errno=%d\n", errno);
- xc_gnttab_munmap(mount->xch, mount->gnth,
+ xc_gnttab_munmap(mount->gnth,
priv_req->page, priv_req->count);
terminate_mount_request(mount);
}
uint16_t req_id;
/* Release the grant */
- if (xc_gnttab_munmap(mount->xch, mount->gnth,
+ if (xc_gnttab_munmap(mount->gnth,
priv_req->page, priv_req->count) != 0) {
FS_DEBUG("ERROR: xc_gnttab_munmap failed errno=%d\n", errno);
terminate_mount_request(mount);
FS_DEBUG("Dispatching remove operation (gref=%d).\n", req->u.fremove.gref);
/* Read the request, and open file */
- file_name = xc_gnttab_map_grant_ref(mount->xch, mount->gnth,
+ file_name = xc_gnttab_map_grant_ref(mount->gnth,
mount->dom_id,
req->u.fremove.gref,
PROT_READ);
ret = remove(file_name);
}
FS_DEBUG("Got ret: %d\n", ret);
- if (xc_gnttab_munmap(mount->xch, mount->gnth, file_name, 1) != 0) {
+ if (xc_gnttab_munmap(mount->gnth, file_name, 1) != 0) {
FS_DEBUG("ERROR: xc_gnttab_munmap failed errno=%d\n", errno);
terminate_mount_request(mount);
}
FS_DEBUG("Dispatching rename operation (gref=%d).\n", req->u.fremove.gref);
/* Read the request, and open file */
- buf = xc_gnttab_map_grant_ref(mount->xch, mount->gnth,
+ buf = xc_gnttab_map_grant_ref(mount->gnth,
mount->dom_id,
req->u.frename.gref,
PROT_READ);
ret = rename(old_file_name, new_file_name);
}
FS_DEBUG("Got ret: %d\n", ret);
- if (xc_gnttab_munmap(mount->xch, mount->gnth, buf, 1) != 0) {
+ if (xc_gnttab_munmap(mount->gnth, buf, 1) != 0) {
FS_DEBUG("ERROR: xc_gnttab_munmap failed errno=%d\n", errno);
terminate_mount_request(mount);
}
/* Read the request, and create file/directory */
mode = req->u.fcreate.mode;
directory = req->u.fcreate.directory;
- file_name = xc_gnttab_map_grant_ref(mount->xch, mount->gnth,
+ file_name = xc_gnttab_map_grant_ref(mount->gnth,
mount->dom_id,
req->u.fcreate.gref,
PROT_READ);
}
}
out:
- if (xc_gnttab_munmap(mount->xch, mount->gnth, file_name, 1) != 0) {
+ if (xc_gnttab_munmap(mount->gnth, file_name, 1) != 0) {
FS_DEBUG("ERROR: xc_gnttab_munmap failed errno=%d\n", errno);
terminate_mount_request(mount);
}
FS_DEBUG("Dispatching list operation (gref=%d).\n", req->u.flist.gref);
/* Read the request, and list directory */
offset = req->u.flist.offset;
- buf = file_name = xc_gnttab_map_grant_ref(mount->xch, mount->gnth,
+ buf = file_name = xc_gnttab_map_grant_ref(mount->gnth,
mount->dom_id,
req->u.flist.gref,
PROT_READ | PROT_WRITE);
ret_val = ((nr_files << NR_FILES_SHIFT) & NR_FILES_MASK) |
((error_code << ERROR_SHIFT) & ERROR_MASK) |
(dirent != NULL ? HAS_MORE_FLAG : 0);
- if (xc_gnttab_munmap(mount->xch, mount->gnth, file_name, 1) != 0) {
+ if (xc_gnttab_munmap(mount->gnth, file_name, 1) != 0) {
FS_DEBUG("ERROR: xc_gnttab_munmap failed errno=%d\n", errno);
terminate_mount_request(mount);
}
FS_DEBUG("Dispatching fs space operation (gref=%d).\n", req->u.fspace.gref);
/* Read the request, and open file */
- file_name = xc_gnttab_map_grant_ref(mount->xch, mount->gnth,
+ file_name = xc_gnttab_map_grant_ref(mount->gnth,
mount->dom_id,
req->u.fspace.gref,
PROT_READ);
if(ret >= 0)
ret = stat.f_bsize * stat.f_bfree;
- if (xc_gnttab_munmap(mount->xch, mount->gnth, file_name, 1) != 0) {
+ if (xc_gnttab_munmap(mount->gnth, file_name, 1) != 0) {
FS_DEBUG("ERROR: xc_gnttab_munmap failed errno=%d\n", errno);
terminate_mount_request(mount);
}
errno = saved_errno;
}
-int xc_gnttab_open(xc_interface *xch)
+int xc_gnttab_open_core(xc_gnttab *xcg)
{
return open(DEVXEN "gntdev", O_RDWR);
}
-int xc_gnttab_close(xc_interface *xch, int xcg_handle)
+int xc_gnttab_close_core(xc_gnttab *xcg)
{
- return close(xcg_handle);
+ return close(xcg->fd);
}
-void *xc_gnttab_map_grant_ref(xc_interface *xch, int xcg_handle,
- uint32_t domid, uint32_t ref, int prot)
+void *xc_gnttab_map_grant_ref(xc_gnttab *xch, uint32_t domid, uint32_t ref, int prot)
{
struct ioctl_gntdev_map_grant_ref map;
void *addr;
map.refs[0].domid = domid;
map.refs[0].ref = ref;
- if ( ioctl(xcg_handle, IOCTL_GNTDEV_MAP_GRANT_REF, &map) ) {
+ if ( ioctl(xch->fd, IOCTL_GNTDEV_MAP_GRANT_REF, &map) ) {
PERROR("xc_gnttab_map_grant_ref: ioctl MAP_GRANT_REF failed");
return NULL;
}
mmap_again:
- addr = mmap(NULL, PAGE_SIZE, prot, MAP_SHARED, xcg_handle, map.index);
+ addr = mmap(NULL, PAGE_SIZE, prot, MAP_SHARED, xch->fd, map.index);
if ( addr == MAP_FAILED )
{
int saved_errno = errno;
PERROR("xc_gnttab_map_grant_ref: mmap failed");
unmap_grant.index = map.index;
unmap_grant.count = 1;
- ioctl(xcg_handle, IOCTL_GNTDEV_UNMAP_GRANT_REF, &unmap_grant);
+ ioctl(xch->fd, IOCTL_GNTDEV_UNMAP_GRANT_REF, &unmap_grant);
errno = saved_errno;
return NULL;
}
return addr;
}
-static void *do_gnttab_map_grant_refs(xc_interface *xch,
- int xcg_handle, uint32_t count,
+static void *do_gnttab_map_grant_refs(xc_gnttab *xch, uint32_t count,
uint32_t *domids, int domids_stride,
uint32_t *refs, int prot)
{
map->count = count;
- if ( ioctl(xcg_handle, IOCTL_GNTDEV_MAP_GRANT_REF, map) ) {
+ if ( ioctl(xch->fd, IOCTL_GNTDEV_MAP_GRANT_REF, map) ) {
PERROR("xc_gnttab_map_grant_refs: ioctl MAP_GRANT_REF failed");
goto out;
}
- addr = mmap(NULL, PAGE_SIZE * count, prot, MAP_SHARED, xcg_handle,
+ addr = mmap(NULL, PAGE_SIZE * count, prot, MAP_SHARED, xch->fd,
map->index);
if ( addr == MAP_FAILED )
{
PERROR("xc_gnttab_map_grant_refs: mmap failed");
unmap_grant.index = map->index;
unmap_grant.count = count;
- ioctl(xcg_handle, IOCTL_GNTDEV_UNMAP_GRANT_REF, &unmap_grant);
+ ioctl(xch->fd, IOCTL_GNTDEV_UNMAP_GRANT_REF, &unmap_grant);
errno = saved_errno;
addr = NULL;
}
return addr;
}
-void *xc_gnttab_map_grant_refs(xc_interface *xch,
- int xcg_handle, uint32_t count, uint32_t *domids,
+void *xc_gnttab_map_grant_refs(xc_gnttab *xcg, uint32_t count, uint32_t *domids,
uint32_t *refs, int prot)
{
- return do_gnttab_map_grant_refs(xch, xcg_handle, count, domids, 1, refs, prot);
+ return do_gnttab_map_grant_refs(xcg, count, domids, 1, refs, prot);
}
-void *xc_gnttab_map_domain_grant_refs(xc_interface *xch,
- int xcg_handle, uint32_t count,
+void *xc_gnttab_map_domain_grant_refs(xc_gnttab *xcg, uint32_t count,
uint32_t domid, uint32_t *refs, int prot)
{
- return do_gnttab_map_grant_refs(xch, xcg_handle, count, &domid, 0, refs, prot);
+ return do_gnttab_map_grant_refs(xcg, count, &domid, 0, refs, prot);
}
-int xc_gnttab_munmap(xc_interface *xch,
- int xcg_handle, void *start_address, uint32_t count)
+int xc_gnttab_munmap(xc_gnttab *xcg, void *start_address, uint32_t count)
{
struct ioctl_gntdev_get_offset_for_vaddr get_offset;
struct ioctl_gntdev_unmap_grant_ref unmap_grant;
* mmap() the pages.
*/
get_offset.vaddr = (unsigned long)start_address;
- if ( (rc = ioctl(xcg_handle, IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR,
+ if ( (rc = ioctl(xcg->fd, IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR,
&get_offset)) )
return rc;
/* Finally, unmap the driver slots used to store the grant information. */
unmap_grant.index = get_offset.offset;
unmap_grant.count = count;
- if ( (rc = ioctl(xcg_handle, IOCTL_GNTDEV_UNMAP_GRANT_REF, &unmap_grant)) )
+ if ( (rc = ioctl(xcg->fd, IOCTL_GNTDEV_UNMAP_GRANT_REF, &unmap_grant)) )
return rc;
return 0;
}
-int xc_gnttab_set_max_grants(xc_interface *xch,
- int xcg_handle, uint32_t count)
+int xc_gnttab_set_max_grants(xc_gnttab *xcg, uint32_t count)
{
struct ioctl_gntdev_set_max_grants set_max;
int rc;
set_max.count = count;
- if ( (rc = ioctl(xcg_handle, IOCTL_GNTDEV_SET_MAX_GRANTS, &set_max)) )
+ if ( (rc = ioctl(xcg->fd, IOCTL_GNTDEV_SET_MAX_GRANTS, &set_max)) )
return rc;
return 0;
fsync(fd);
}
-int xc_gnttab_open(xc_interface *xch)
+int xc_gnttab_open_core(xc_gnttab *xcg)
{
- int xcg_handle;
- xcg_handle = alloc_fd(FTYPE_GNTMAP);
- gntmap_init(&files[xcg_handle].gntmap);
- return xcg_handle;
+ int fd;
+ fd = alloc_fd(FTYPE_GNTMAP);
+ gntmap_init(&files[fd].gntmap);
+ return fd;
}
-int xc_gnttab_close(xc_interface *xch, int xcg_handle)
+int xc_gnttab_close_core(xc_gnttab *xcg)
{
- return close(xcg_handle);
+ return close(xcg->fd);
}
void minios_gnttab_close_fd(int fd)
files[fd].type = FTYPE_NONE;
}
-void *xc_gnttab_map_grant_ref(xc_interface *xch, int xcg_handle,
+void *xc_gnttab_map_grant_ref(xc_gnttab *xcg,
uint32_t domid,
uint32_t ref,
int prot)
{
- return gntmap_map_grant_refs(&files[xcg_handle].gntmap,
+ return gntmap_map_grant_refs(&files[xcg->fd].gntmap,
1,
&domid, 0,
&ref,
prot & PROT_WRITE);
}
-void *xc_gnttab_map_grant_refs(xc_interface *xch, int xcg_handle,
+void *xc_gnttab_map_grant_refs(xc_gnttab *xcg,
uint32_t count,
uint32_t *domids,
uint32_t *refs,
int prot)
{
- return gntmap_map_grant_refs(&files[xcg_handle].gntmap,
+ return gntmap_map_grant_refs(&files[xcg->fd].gntmap,
count,
domids, 1,
refs,
prot & PROT_WRITE);
}
-void *xc_gnttab_map_domain_grant_refs(xc_interface *xch, int xcg_handle,
+void *xc_gnttab_map_domain_grant_refs(xc_gnttab *xcg,
uint32_t count,
uint32_t domid,
uint32_t *refs,
int prot)
{
- return gntmap_map_grant_refs(&files[xcg_handle].gntmap,
+ return gntmap_map_grant_refs(&files[xcg->fd].gntmap,
count,
&domid, 0,
refs,
prot & PROT_WRITE);
}
-int xc_gnttab_munmap(xc_interface *xch, int xcg_handle,
+int xc_gnttab_munmap(xc_gnttab *xcg,
void *start_address,
uint32_t count)
{
int ret;
- ret = gntmap_munmap(&files[xcg_handle].gntmap,
+ ret = gntmap_munmap(&files[xcg->fd].gntmap,
(unsigned long) start_address,
count);
if (ret < 0) {
return ret;
}
-int xc_gnttab_set_max_grants(xc_interface *xch, int xcg_handle,
+int xc_gnttab_set_max_grants(xc_gnttab *xcg,
uint32_t count)
{
int ret;
- ret = gntmap_set_max_grants(&files[xcg_handle].gntmap,
+ ret = gntmap_set_max_grants(&files[xcg->fd].gntmap,
count);
if (ret < 0) {
errno = -ret;
return xc_interface_close_common(xce, &xc_evtchn_close_core);
}
+xc_gnttab *xc_gnttab_open(xentoollog_logger *logger,
+ unsigned open_flags)
+{
+ return xc_interface_open_common(logger, NULL, open_flags,
+ XC_INTERFACE_GNTTAB, &xc_gnttab_open_core);
+}
+
+int xc_gnttab_close(xc_gnttab *xcg)
+{
+ return xc_interface_close_common(xcg, &xc_gnttab_close_core);
+}
+
static pthread_key_t errbuf_pkey;
static pthread_once_t errbuf_pkey_once = PTHREAD_ONCE_INIT;
enum xc_interface_type {
XC_INTERFACE_PRIVCMD,
XC_INTERFACE_EVTCHN,
+ XC_INTERFACE_GNTTAB,
};
struct xc_interface_core {
int xc_evtchn_open_core(struct xc_interface_core *xce); /* returns fd, logs errors */
int xc_evtchn_close_core(struct xc_interface_core *xce); /* no logging */
+int xc_gnttab_open_core(struct xc_interface_core *xcg); /* returns fd, logs errors */
+int xc_gnttab_close_core(struct xc_interface_core *xcg); /* no logging */
+
void *xc_map_foreign_ranges(xc_interface *xch, uint32_t dom,
size_t size, int prot, size_t chunksize,
privcmd_mmap_entry_t entries[], int nentries);
typedef struct xc_interface_core xc_interface;
typedef struct xc_interface_core xc_evtchn;
+typedef struct xc_interface_core xc_gnttab;
typedef enum xc_error_code xc_error_code;
/*
* Return an fd onto the grant table driver. Logs errors.
*/
-int xc_gnttab_open(xc_interface *xch);
+xc_gnttab *xc_gnttab_open(xentoollog_logger *logger,
+ unsigned open_flags);
/*
* Close a handle previously allocated with xc_gnttab_open().
* Never logs errors.
*/
-int xc_gnttab_close(xc_interface *xch, int xcg_handle);
+int xc_gnttab_close(xc_gnttab *xcg);
/*
* Memory maps a grant reference from one domain to a local address range.
* Mappings should be unmapped with xc_gnttab_munmap. Logs errors.
*
- * @parm xcg_handle a handle on an open grant table interface
+ * @parm xcg a handle on an open grant table interface
* @parm domid the domain to map memory from
* @parm ref the grant reference ID to map
* @parm prot same flag as in mmap()
*/
-void *xc_gnttab_map_grant_ref(xc_interface *xch,
- int xcg_handle,
+void *xc_gnttab_map_grant_ref(xc_gnttab *xcg,
uint32_t domid,
uint32_t ref,
int prot);
* contiguous local address range. Mappings should be unmapped with
* xc_gnttab_munmap. Logs errors.
*
- * @parm xcg_handle a handle on an open grant table interface
+ * @parm xcg a handle on an open grant table interface
* @parm count the number of grant references to be mapped
* @parm domids an array of @count domain IDs by which the corresponding @refs
* were granted
* @parm refs an array of @count grant references to be mapped
* @parm prot same flag as in mmap()
*/
-void *xc_gnttab_map_grant_refs(xc_interface *xch,
- int xcg_handle,
+void *xc_gnttab_map_grant_refs(xc_gnttab *xcg,
uint32_t count,
uint32_t *domids,
uint32_t *refs,
* contiguous local address range. Mappings should be unmapped with
* xc_gnttab_munmap. Logs errors.
*
- * @parm xcg_handle a handle on an open grant table interface
+ * @parm xcg a handle on an open grant table interface
* @parm count the number of grant references to be mapped
* @parm domid the domain to map memory from
* @parm refs an array of @count grant references to be mapped
* @parm prot same flag as in mmap()
*/
-void *xc_gnttab_map_domain_grant_refs(xc_interface *xch,
- int xcg_handle,
+void *xc_gnttab_map_domain_grant_refs(xc_gnttab *xcg,
uint32_t count,
uint32_t domid,
uint32_t *refs,
* Unmaps the @count pages starting at @start_address, which were mapped by a
* call to xc_gnttab_map_grant_ref or xc_gnttab_map_grant_refs. Never logs.
*/
-int xc_gnttab_munmap(xc_interface *xch,
- int xcg_handle,
+int xc_gnttab_munmap(xc_gnttab *xcg,
void *start_address,
uint32_t count);
* and it may not be possible to satisfy requests up to the maximum number
* of grants.
*/
-int xc_gnttab_set_max_grants(xc_interface *xch,
- int xcg_handle,
+int xc_gnttab_set_max_grants(xc_gnttab *xcg,
uint32_t count);
int xc_gnttab_op(xc_interface *xch, int cmd,